package Controller;

import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import javax.swing.JFrame;

import Controller.MainController;
import Controller.listeners.NewtonsIncreaseListener;
import Controller.listeners.NewtonsListener;
import Controller.listeners.RegulaFalsiIncreaseListener;
import Controller.listeners.RegulaFalsiListener;

import Model.Newtons;
import Model.RegulaFalsi;
import View.MainView;

public class MainController {

	public static void main(String args[]) {
		new MainController();
	}
	
	public MainController(){
		JFrame frame = new JFrame();
		Rectangle rec = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
		frame.setSize(rec.width, rec.height);
		frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setTitle("Regula Falsi and Newtons Simulation");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        MainView view = new MainView();
        RegulaFalsi regulaFalsi = new RegulaFalsi();
        Newtons newtons = new Newtons();
		frame.getContentPane().add(view);
		frame.setVisible(true);

		RegulaFalsiIncreaseListener rListener = new RegulaFalsiIncreaseListener(view, regulaFalsi);
		NewtonsIncreaseListener nListener = new NewtonsIncreaseListener(view, newtons);
		RegulaFalsiListener regulaListener = new RegulaFalsiListener(view, regulaFalsi);
		NewtonsListener newtonsListener = new NewtonsListener(view, newtons);
		
		view.setRegulaFalsiListener(regulaListener);
		view.setNewtonsListener(newtonsListener);
		view.setSimulateRegulaFalsiListener(rListener);
		view.setSimulateNewtonsListener(nListener);
	}
}
